<script>
import store from '@/store'
export default {
  onLaunch: async function () {
    // 获取手机相关的  例如状态栏等等
    this.getPhoneStatusBar();
    // 获取字典相关的东西
    this.$store.dispatch("asyncDictionaryEntry");
  },
  onShow: function () {

  },
  onHide: function () {

  },
  // 对加载到没有的页面进行重定向
  onPageNotFound: function () {
    uni.switchTab({
      url: "/pages/home/index",
    });
  },
  methods: {
    // 获取手机状态栏的情况
    getPhoneStatusBar () {
      var statusBar = 0; //状态栏高度
      var customBar = 0; // 状态栏高度 + 导航栏高度
      var navbar = 0; // 自定义标题与胶囊对齐高度getSystemInfoSync
      uni.getSystemInfo({
        success: (e) => {
          // #ifdef MP
          statusBar = e.statusBarHeight;
          customBar = e.statusBarHeight + 45;
          if (e.platform === "android") {
            customBar = e.statusBarHeight + 50;
          }
          // #endif

          // #ifdef MP-WEIXIN
          statusBar = e.statusBarHeight;
          const custom = wx.getMenuButtonBoundingClientRect();
          customBar = custom.bottom + custom.top - e.statusBarHeight;

          navbar = (custom.top - e.statusBarHeight) * 2 + custom.height;
          // #endif

          // #ifdef MP-ALIPAY
          statusBar = e.statusBarHeight;
          customBar = e.statusBarHeight + e.titleBarHeight;
          // #endif

          // #ifdef APP-PLUS
          statusBar = e.statusBarHeight;
          customBar = e.statusBarHeight + 45;
          // #endif

          // #ifdef H5
          statusBar = 0;
          customBar = e.statusBarHeight + 45;
          // #endif
        },
      });
      store.commit("getNavigationBarHeight", {
        statusBar,
        customBar,
        navbar,
      });
    },
  },
};
</script>

<style lang="scss">
</style>